<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\Organization\Http\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

/**
 * 工区账号公司关联表验证数据类
 */
class RdOrganizeUserRequest extends FormRequest
{
    /**
     * 场景配置
     */
    protected array $scenes = [
        'index' => [
            'user_id',
            'enterprise_id',
            'wechat_openid',
            'department',
            'position',
            'created_at',
            'updated_at',
        ],
        'create' => [
            'user_id',
            'enterprise_id',
            'wechat_openid',
            'extra_data',
            'department',
            'position',
            'remark'
        ],
        'update' => [
            'user_id',
            'enterprise_id',
            'wechat_openid',
            'extra_data',
            'department',
            'position',
            'remark'
        ],
        'login' => [
            'js_code',
            'type'
        ],
        'bind' => [
            'phone',
            'open_id',
            'vcode',
            'enterprise_id',
            'code'
        ],
        'vcode' => [
            'phone',
            'code'
        ]
    ];

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            'enterprise_id' => 'integer|min:1',
            'wechat_openid' => 'string|max:64',
            'extra_data' => 'array',
            'department' => 'string|max:64',
            'position' => 'string|max:64',
            'remark' => 'string|max:255',
            'created_at' => 'integer|min:1',
            'updated_at' => 'integer|min:1',
            'user_id' => 'integer|min:1',

            'js_code' => 'string|max:64',
            'type' => 'in:1,2,3',
            'phone' => 'string|size:11|regex:/^1[3456789]\d{9}$/',
            'open_id' => 'string|max:64',
            'vcode' => 'string|max:8',
            'code' => 'string|max:6',
        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'user_id' => '用户id',
            'enterprise_id' => '企业id',
            'phone' => '手机号',
            'openid' => '微信openid',
            'extra_data' => '额外数据',
            'department' => '部门',
            'position' => '职位',
            'created_by' => '创建者',
            'updated_by' => '更新者',
            'remark' => '备注',
            'js_code' => '微信登录code',
            'type' => '登录类型',
            'vcode' => '验证码',
            'code' => '区号',

        ];
    }

public function messages(): array
{
    return [
    ];
}
}